<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Classes  Reference</title>
    <link rel="stylesheet" type="text/css" href="css/jazzy.css" />
    <link rel="stylesheet" type="text/css" href="css/highlight.css" />
    <meta charset="utf-8">
    <script src="js/jquery.min.js" defer></script>
    <script src="js/jazzy.js" defer></script>
    
    <script src="js/lunr.min.js" defer></script>
    <script src="js/typeahead.jquery.js" defer></script>
    <script src="js/jazzy.search.js" defer></script>
  </head>
  <body>

    <a name="//apple_ref/swift/Section/Classes" class="dashAnchor"></a>

    <a title="Classes  Reference"></a>

    <header class="header">
      <p class="header-col header-col--primary">
        <a class="header-link" href="index.html">
          Katana 5.1.1 Docs
        </a>
         (99% documented)
      </p>
    
      <p class="header-col--secondary">
        <form role="search" action="search.json">
          <input type="text" placeholder="Search documentation" data-typeahead>
        </form>
      </p>
    
        <p class="header-col header-col--secondary">
          <a class="header-link" href="https://github.com/BendingSpoons/katana-swift">
            <img class="header-icon" src="img/gh.png"/>
            View on GitHub
          </a>
        </p>
    
    </header>

    <p class="breadcrumbs">
      <a class="breadcrumb" href="index.html">Katana Reference</a>
      <img class="carat" src="img/carat.png" />
      Classes  Reference
    </p>

    <div class="content-wrapper">
      <nav class="navigation">
        <ul class="nav-groups">
          <li class="nav-group-name">
            <a class="nav-group-name-link" href="Classes.html">Classes</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Classes/EmptySideEffectDependencyContainer.html">EmptySideEffectDependencyContainer</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Classes/PartialStore.html">PartialStore</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Classes/Store.html">Store</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Classes/Store/Configuration.html">– Configuration</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a class="nav-group-name-link" href="Enums.html">Enumerations</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Enums/DispatchableLogger.html">DispatchableLogger</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a class="nav-group-name-link" href="Extensions.html">Extensions</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Extensions/DispatchQueue.html">DispatchQueue</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a class="nav-group-name-link" href="Protocols.html">Protocols</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Protocols/AnySideEffect.html">AnySideEffect</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Protocols/AnySideEffectContext.html">AnySideEffectContext</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Protocols/AnyStateUpdater.html">AnyStateUpdater</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Protocols/AnyStore.html">AnyStore</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Protocols/AsyncProvider.html">AsyncProvider</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Protocols/DispatchObserverDispatchable.html">DispatchObserverDispatchable</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Protocols/Dispatchable.html">Dispatchable</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Protocols/NotificationObserverDispatchable.html">NotificationObserverDispatchable</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Protocols/OnStartObserverDispatchable.html">OnStartObserverDispatchable</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Protocols/ReturningSideEffect.html">ReturningSideEffect</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Protocols/SideEffect.html">SideEffect</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Protocols/SideEffectDependencyContainer.html">SideEffectDependencyContainer</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Protocols/State.html">State</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Protocols/StateObserverDispatchable.html">StateObserverDispatchable</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Protocols/StateUpdater.html">StateUpdater</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a class="nav-group-name-link" href="Structs.html">Structures</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Structs/ObserverInterceptor.html">ObserverInterceptor</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Structs/ObserverInterceptor/ObserverType.html">– ObserverType</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Structs/SideEffectContext.html">SideEffectContext</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Structs/SignpostLogger.html">SignpostLogger</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a class="nav-group-name-link" href="Typealiases.html">Type Aliases</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Typealiases.html#/s:6Katana11AnyDispatcha">AnyDispatch</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Typealiases.html#/s:6Katana16AnyStoreListenera">AnyStoreListener</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Typealiases.html#/s:6Katana8GetStatea">GetState</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Typealiases.html#/s:6Katana16StoreInterceptora">StoreInterceptor</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Typealiases.html#/s:6Katana20StoreInterceptorNexta">StoreInterceptorNext</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Typealiases.html#/s:6Katana13StoreListenera">StoreListener</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Typealiases.html#/s:6Katana16StoreUnsubscribea">StoreUnsubscribe</a>
              </li>
            </ul>
          </li>
        </ul>
      </nav>
      <article class="main-content">

        <section class="section">
          <div class="section-content top-matter">
            <h1>Classes</h1>
            <p>The following classes are available globally.</p>

          </div>
        </section>

        <section class="section">
          <div class="section-content">
            <div class="task-group">
              <ul class="item-container">
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:6Katana34EmptySideEffectDependencyContainerC"></a>
                    <a name="//apple_ref/swift/Class/EmptySideEffectDependencyContainer" class="dashAnchor"></a>
                    <a class="token" href="#/s:6Katana34EmptySideEffectDependencyContainerC">EmptySideEffectDependencyContainer</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>An empty dependencies container. It can be used for testing purposes or you don&rsquo;t need dependencies</p>

                        <a href="Classes/EmptySideEffectDependencyContainer.html" class="slightly-smaller">See more</a>
                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kt">EmptySideEffectDependencyContainer</span> <span class="p">:</span> <span class="kt"><a href="Protocols/SideEffectDependencyContainer.html">SideEffectDependencyContainer</a></span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/BendingSpoons/katana-swift/blob/master//Sources/SideEffectDependencyContainer.swift#L26-L34">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:6Katana12PartialStoreC"></a>
                    <a name="//apple_ref/swift/Class/PartialStore" class="dashAnchor"></a>
                    <a class="token" href="#/s:6Katana12PartialStoreC">PartialStore</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Helper Store type that is used as a partial type.</p>

<p>This type is very helpful when you want to pass the store to pieces of your application
that must be aware of the type of state that the app manages but they should not care about
the logic part (that is, the dependency container). A very common case is when you want to
pass the store to the UI of your application. The UI shouldn&rsquo;t access to the dependency container
directly (it should dispatch a <code><a href="Protocols/SideEffect.html">SideEffect</a></code> instead) but you can still have type-safety over the
state type that is managed.</p>
<div class="aside aside-warning">
    <p class="aside-title">Warning</p>
    you should not create this class directly. The class is meant to be used as a partial type
erasure system over <code><a href="Classes/Store.html">Store</a></code>

</div>

                        <a href="Classes/PartialStore.html" class="slightly-smaller">See more</a>
                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight swift"><code><span class="kd">open</span> <span class="kd">class</span> <span class="kt">PartialStore</span><span class="o">&lt;</span><span class="kt">S</span><span class="o">&gt;</span> <span class="p">:</span> <span class="kt"><a href="Protocols/AnyStore.html">AnyStore</a></span> <span class="k">where</span> <span class="kt">S</span> <span class="p">:</span> <span class="kt"><a href="Protocols/State.html">State</a></span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/BendingSpoons/katana-swift/blob/master//Sources/Store.swift#L78-L162">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:6Katana5StoreC"></a>
                    <a name="//apple_ref/swift/Class/Store" class="dashAnchor"></a>
                    <a class="token" href="#/s:6Katana5StoreC">Store</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>The <code>Store</code> is a sort of single entry point that handles the logic of your application.
In Katana, all the various pieces of information that your application manages should be stored
in a single atom, called state (see also <code><a href="Protocols/State.html">State</a></code> protocol).</p>

<p>The <code>Store</code>, however, doesn&rsquo;t really implements any application specific logic: this class
only manages operations that are requested by the application-specific logic. In particular,
you can require the <code>Store</code> to execute something by <code>dispatching a dispatchable item</code>.</p>

<p>Currently the store handles 2 types of dispatchable: <code>State Updater</code>, <code>Side Effect</code></p>
<h4 id='update-the-state' class='heading'>Update the state</h4>

<p>As written before, in Katana every relevant information in the application should be stored in the
Store&rsquo;s state. The only way to update the state is to dispatch a <code><a href="Protocols/StateUpdater.html">StateUpdater</a></code>.
At this point the <code>Store</code> will execute the following operations:</p>

<ul>
<li>it executes the interceptors</li>
<li>it creates the new state, by invoking the <code>updateState</code> function of the <code><a href="Protocols/StateUpdater.html">StateUpdater</a></code></li>
<li>it updates the state</li>
<li>it resolves the promise</li>
</ul>
<h4 id='handle-to-business-logic' class='heading'>Handle to Business Logic</h4>

<p>Non trivial applications require to interact with external services and/or implement complex logics.
The proper way to handle these is by dispatching a <code><a href="Protocols/SideEffect.html">SideEffect</a></code>.
The <code>Store</code> will execute the following operations:</p>

<ul>
<li>it executes the interceptors</li>
<li>it executes the <code><a href="Protocols/SideEffect.html">SideEffect</a></code> body</li>
<li>it resolves the promise</li>
</ul>
<h4 id='listen-for-updates' class='heading'>Listen for updates</h4>

<p>You can attach a listener that is invoked every time the state changes by using <code>addListener</code>.</p>
<h4 id='intercept-dispatchable' class='heading'>Intercept Dispatchable</h4>

<p>It is possible to intercept and reshape the behaviour of the <code>Store</code> by using a <code><a href="Typealiases.html#/s:6Katana16StoreInterceptora">StoreInterceptor</a></code>.
A <code><a href="Typealiases.html#/s:6Katana16StoreInterceptora">StoreInterceptor</a></code> is executed every time something has dispatched, and before it is actually
managed by the <code>Store</code>. Here you implement behaviours like logging, blocking items before they&rsquo;re executed
and even change dynamically which dispatchable items arrive to the <code>Store</code> itself.</p>
<div class="aside aside-see-also">
    <p class="aside-title">See also</p>
    <code><a href="Protocols/StateUpdater.html">StateUpdater</a></code> for more information about how to implement an update of the state

</div><div class="aside aside-see-also">
    <p class="aside-title">See also</p>
    <code><a href="Protocols/SideEffect.html">SideEffect</a></code> for more information about how to implement a complex/asynchronous logic

</div>

                        <a href="Classes/Store.html" class="slightly-smaller">See more</a>
                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight swift"><code><span class="kd">open</span> <span class="kd">class</span> <span class="kt">Store</span><span class="o">&lt;</span><span class="kt">S</span><span class="p">,</span> <span class="kt">D</span><span class="o">&gt;</span> <span class="p">:</span> <span class="kt"><a href="Classes/PartialStore.html">PartialStore</a></span><span class="o">&lt;</span><span class="kt">S</span><span class="o">&gt;</span> <span class="k">where</span> <span class="kt">S</span> <span class="p">:</span> <span class="kt"><a href="Protocols/State.html">State</a></span><span class="p">,</span> <span class="kt">D</span> <span class="p">:</span> <span class="kt"><a href="Protocols/SideEffectDependencyContainer.html">SideEffectDependencyContainer</a></span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/BendingSpoons/katana-swift/blob/master//Sources/Store.swift#L211-L559">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
          </div>
        </section>

      </article>
    </div>
    <section class="footer">
      <p>&copy; 2021 <a class="link" href="http://bendingspoons.com" target="_blank" rel="external">Bending Spoons Team</a>. All rights reserved. (Last updated: 2021-04-29)</p>
      <p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.13.6</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
    </section>
  </body>
</div>
</html>
